package com.dailyblue.java.spring.ioc.demo7;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class Printer {
    @Autowired
    @Qualifier("greyInk")
    private Ink ink;
    @Resource(name = "a6Paper")
    private Paper paper;

    public void print(String str) {
        System.out.println("开始打印！");
        System.out.println("装载墨盒：" + ink.getColor());
        int lineSize = paper.getSize();
        for (int i = 0; i < str.length(); i++) {
            System.out.print(str.charAt(i));
            if ((i + 1) % lineSize == 0) {
                System.out.println("");
            }
        }
    }
}
